/*
 * Copyright (c) 2010, VeRSI Consortium
 *   (Victorian eResearch Strategic Initiative, Australia)
 * All rights reserved.
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of the VeRSI, the VeRSI Consortium members, nor the
 *       names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
package versi.vitro.oaiserviceprovider.service.handle.api;

import versi.vitro.oaiserviceprovider.service.handle.helper.HandleHelper;

/**
 * Service for managing Handle.
 */
public interface HandleService {

    /**
     * Sets the namespace of the handle which to be used.
     * 
     * @param handleNamespace
     *            handleNamespace.
     */
    void setHandleNamespace(final String handleNamespace);

    /**
     * Sets the server key of the handle which to be used.
     * 
     * @param handleServerKey
     *            handleServerKey.
     */
    void setHandleServerKey(final String handleServerKey);

    /**
     * Sets the key pass phrase of the handle which to be used.
     * 
     * @param keyPassphrase
     *            keyPassphrase.
     */
    void setKeyPassphrase(final String keyPassphrase);

    /**
     * Config the key pass phrase of the handle which to be used.
     * 
     * @param handleNamespace
     *            handleNamespace.
     * @param handleServerKey
     *            handleServerKey.
     * @param keyPassphrase
     *            keyPassphrase.
     */
    void configHandle(final String handleNamespace, final String handleServerKey, final String keyPassphrase);

    /**
     * Create a Handle for a given URL.
     * 
     * @param url
     *            Url that need to assign a handle.
     * @return Sting Handle for the given URL.
     */
 /*   String createHandleforURL(final String url);*/

    /**
     * Creates a Handle for a given URL by using ANDS services.
     * 
     * @param resourceType
     *            Either Description or URL.
     * 
     * @param resourceValue
     *            Value that need to assign a handle.
     * 
     * @return Sting Created Handle for the given URL.
     */
    String pidCreateHandle(final String resourceType, final String resourceValue);

    /**
     * Creates a Handle for a given URL by using ANDS services.
     * 
     * @param resourceType
     *            Either Description or URL.
     * 
     * @param resourceValue
     *            Value that need to assign a handle.
     * @param index
     *            Index of the value within the handle needed to be created.
     * 
     * @return Sting Created handle for the given URL.
     */
    String pidCreateHandle(final String resourceType, final String resourceValue, final int index);

    /**
     * Gets the Helper class for Handle Service.
     * 
     * @return HandleHelper Helper class for Handle Service.
     */
    HandleHelper getHandleHelper();

    /**
     * Configures ANDS handle service.
     * 
     * @param url
     *            ANDS service URL.
     * @param AppId
     *            ANDS service AppId.
     * @param identifier
     *            ANDS service identifier.
     * @param authDomain
     *            ANDS service authDomain.
     */
    void configureANDSHandleService(final String url, final String AppId, final String identifier,
	    final String authDomain);

    /**
     * Deletes a value associated with an existing handle.
     * 
     * @param handle
     *            The handle from which a value is to be deleted.
     * @param index
     *            Index of the value within the handle needed to be deleted.
     * @return boolean  True if successful delete a handle value, false otherwise.
     */
    boolean pidDeleteHandleValue(final String handle, final int index);

    /**
     * Changes a value associated with an existing handle.
     * 
     * @param handle
     *            The handle from which a value is to be modified.c
     * @param index
     *            Index of the value within the handle needed to be changed.
     * @param resourceValue
     * @return boolean True if successful modify a handle value, false otherwise.
     */
    boolean pidModifyHandleValue(final String handle, final int index, final String resourceValue);

    /**
     * Adds a value to an existing handle.
     * 
     * @param handle
     *            The handle from which a value is to be added.
     * @param resourceType
     *            Either Description or URL.
     * @param resourceValue
     *            Value that need to be added to a handle.
     * @return String
     */
    String pidAddHandleValue(final String handle, final String resourceType, final String resourceValue);

    /**
     * Adds a value to an existing handle.
     * 
     * @param handle
     *            The handle from which a value is to be added.
     * @param resourceType
     *            Either Description or URL.
     * @param resourceValue
     *            Value that need to be added to the handle.
     * @param index
     *            Index of the added value within the handle. ` `
     * @return String
     */
    String pidAddHandleValue(final String handle, final String resourceType, final String resourceValue, final int index);

    /**
     * Returns a list of handles owned by the requestor, an owner being a
     * combination of identifier and authDomain passed in the body of the
     * request.
     * 
     * @return String[] A list of handle owned by the requestor.
     */
    String[] pidListHandle();

}
